/*==============================================================================
             Copyright (c) 2009 - All rights reserved
================================================================================
File description:

    HighLight function definition

================================================================================
      Date            Name                    Description of Change
28-Aug-2009  Xiaofeng.Gu                    Written
$HISTORY$
==============================================================================*/
#include "stdafx.h"
#include "HighLight.h"
#include <algorithm>

CHighLightSet::CHighLightSet()
{
}

CHighLightSet::~CHighLightSet()
{
	Clear();
}

void CHighLightSet::Add(CHighLight* pObj)
{
	HighLightSet::iterator it;
	it = std::find(m_HighLightSet.begin(), m_HighLightSet.end(), pObj);
	if (it == m_HighLightSet.end())
	{
		pObj->HighLight(true);
		m_HighLightSet.push_back(pObj);
	}
}

void CHighLightSet::Delete(CHighLight* pObj)
{
	pObj->HighLight(false);
	HighLightSet::iterator it;
	it = std::find(m_HighLightSet.begin(), m_HighLightSet.end(), pObj);
	if (it != m_HighLightSet.end())
	{
		m_HighLightSet.erase(it);
	}
}

void CHighLightSet::Clear()
{
	m_HighLightSet.clear();
}

long CHighLightSet::GetCount()
{
	return (long)(m_HighLightSet.size());
}

CHighLight* CHighLightSet::GetObject(long lAt)
{
	return m_HighLightSet[lAt];
}

void CHighLightSet::Reset()
{
	for (HighLightSet::iterator it = m_HighLightSet.begin();
		it != m_HighLightSet.end(); it ++)
	{
		(*it)->HighLight(false);
	}
	Clear();
}